/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * RadSaTreninzima.java
 *
 * Created on Jun 23, 2010, 6:07:24 PM
 */

package klijent.gui;

import klijent.kontrolerKI.KontrolerKITrening;

/**
 *
 * @author Porodica Ivic
 */
public class RadSaTreninzima extends javax.swing.JFrame {

    /** Creates new form RadSaTreninzima */
    public RadSaTreninzima() {
        initComponents();
        setLocationRelativeTo(null);
        setResizable(false);
        KontrolerKITrening.pripremiFormuRadSaTreninzima(jtTreninzi, jbSacuvaj, jbObrisi);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel13 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jtxtSifraTreninga = new javax.swing.JTextField();
        jtxtNazivTreninga = new javax.swing.JTextField();
        jtxtCena = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jtxtBrojTermina = new javax.swing.JTextField();
        jtxtBrojDanaTrajanja = new javax.swing.JTextField();
        jtxtVremeMaxDolaska = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        jbKreiraj = new javax.swing.JButton();
        jbSacuvaj = new javax.swing.JButton();
        jbObrisi = new javax.swing.JButton();
        jSeparator1 = new javax.swing.JSeparator();
        jScrollPane1 = new javax.swing.JScrollPane();
        jtTreninzi = new javax.swing.JTable();
        jbSelektujTrening = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Rad sa treninzima");

        jLabel13.setFont(new java.awt.Font("Mangal", 0, 18));
        jLabel13.setText("Unestite podatke o treningu:");

        jLabel1.setText("Sifra Treninga:");

        jLabel2.setText("Naziv Treninga:");

        jLabel3.setText("Cena:");

        jLabel4.setText("Broj termina:");

        jLabel5.setText("Broj dana trajanja");

        jLabel6.setText("Vreme max dolaska:");

        jLabel7.setText("din.");

        jLabel8.setText("h");

        jbKreiraj.setText("Ubaci Trening");
        jbKreiraj.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbKreirajActionPerformed(evt);
            }
        });

        jbSacuvaj.setText("Sacuvaj podatke o treningu");
        jbSacuvaj.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbSacuvajActionPerformed(evt);
            }
        });

        jbObrisi.setText("Obrisi Trening");
        jbObrisi.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbObrisiActionPerformed(evt);
            }
        });

        jtTreninzi.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jtTreninzi.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
        jScrollPane1.setViewportView(jtTreninzi);

        jbSelektujTrening.setText("Selektuj Trening");
        jbSelektujTrening.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbSelektujTreningActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(14, 14, 14)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addGroup(layout.createSequentialGroup()
                                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                    .addComponent(jLabel1)
                                                    .addComponent(jLabel2)
                                                    .addComponent(jLabel3)
                                                    .addComponent(jLabel5)
                                                    .addComponent(jLabel4))
                                                .addGap(33, 33, 33)
                                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                                        .addComponent(jtxtNazivTreninga)
                                                        .addComponent(jtxtSifraTreninga, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE))
                                                    .addGroup(layout.createSequentialGroup()
                                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                                            .addComponent(jtxtBrojDanaTrajanja, javax.swing.GroupLayout.Alignment.LEADING)
                                                            .addComponent(jtxtBrojTermina, javax.swing.GroupLayout.Alignment.LEADING)
                                                            .addComponent(jtxtCena, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE))
                                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                            .addComponent(jbSacuvaj)
                                                            .addComponent(jLabel7)))))
                                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                                .addComponent(jbKreiraj, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                                    .addComponent(jLabel6)
                                                    .addGap(18, 18, 18)
                                                    .addComponent(jtxtVremeMaxDolaska, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                                    .addComponent(jLabel8))))
                                        .addGap(18, 18, 18)
                                        .addComponent(jbObrisi, javax.swing.GroupLayout.PREFERRED_SIZE, 191, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(layout.createSequentialGroup()
                                        .addGap(11, 11, 11)
                                        .addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, 268, javax.swing.GroupLayout.PREFERRED_SIZE))))
                            .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 681, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(37, 37, 37)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jbSelektujTrening, javax.swing.GroupLayout.PREFERRED_SIZE, 141, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 542, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(157, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 251, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jbSelektujTrening)
                .addGap(15, 15, 15)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jtxtSifraTreninga, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(24, 24, 24)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jtxtNazivTreninga, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(21, 21, 21)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel3)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jtxtCena, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel7))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jtxtBrojTermina, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel4))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jtxtBrojDanaTrajanja, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel5))))
                .addGap(28, 28, 28)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jtxtVremeMaxDolaska, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel8)
                    .addComponent(jLabel6))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jbKreiraj)
                    .addComponent(jbSacuvaj)
                    .addComponent(jbObrisi))
                .addContainerGap(60, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jbKreirajActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbKreirajActionPerformed
        // TODO add your handling code here:
        KontrolerKITrening.kreirajTrening(jtxtSifraTreninga, jtxtNazivTreninga, jtxtCena, jtxtBrojTermina, jtxtBrojDanaTrajanja, jtxtVremeMaxDolaska, jtTreninzi);
    }//GEN-LAST:event_jbKreirajActionPerformed

    private void jbSacuvajActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbSacuvajActionPerformed
        // TODO add your handling code here:
        KontrolerKITrening.sacuvajTrening(jtxtSifraTreninga, jtxtNazivTreninga, jtxtCena, jtxtBrojTermina, jtxtBrojDanaTrajanja, jtxtVremeMaxDolaska, jtTreninzi, jbKreiraj, jbSacuvaj, jbObrisi);
    }//GEN-LAST:event_jbSacuvajActionPerformed

    private void jbSelektujTreningActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbSelektujTreningActionPerformed
        // TODO add your handling code here:
        KontrolerKITrening.vratiSelektovaniTrening(jtTreninzi, jtxtSifraTreninga, jtxtNazivTreninga, jtxtCena, jtxtBrojTermina, jtxtBrojDanaTrajanja, jtxtVremeMaxDolaska, jbSacuvaj, jbObrisi, jbKreiraj);
    }//GEN-LAST:event_jbSelektujTreningActionPerformed

    private void jbObrisiActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbObrisiActionPerformed
        // TODO add your handling code here:
        KontrolerKITrening.obrisiTrening(jtxtSifraTreninga, jtxtNazivTreninga, jtxtCena, jtxtBrojTermina, jtxtBrojDanaTrajanja, jtxtVremeMaxDolaska, jtTreninzi, jbKreiraj, jbSacuvaj, jbObrisi);
    }//GEN-LAST:event_jbObrisiActionPerformed

    /**
    * @param args the command line arguments
    */
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JButton jbKreiraj;
    private javax.swing.JButton jbObrisi;
    private javax.swing.JButton jbSacuvaj;
    private javax.swing.JButton jbSelektujTrening;
    private javax.swing.JTable jtTreninzi;
    private javax.swing.JTextField jtxtBrojDanaTrajanja;
    private javax.swing.JTextField jtxtBrojTermina;
    private javax.swing.JTextField jtxtCena;
    private javax.swing.JTextField jtxtNazivTreninga;
    private javax.swing.JTextField jtxtSifraTreninga;
    private javax.swing.JTextField jtxtVremeMaxDolaska;
    // End of variables declaration//GEN-END:variables

}
